﻿<UserControl x:Class="Songhay.Silverlight.BiggestBox.Views.ClientView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:sdk="clr-namespace:System.Windows;assembly=System.Windows.Controls"
    xmlns:sdkctrls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:toolkitInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
    xmlns:v="clr-namespace:Songhay.Silverlight.BiggestBox.Views"
    xmlns:vm="clr-namespace:Songhay.Silverlight.BiggestBox.ViewModels"
    HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
    MinWidth="480" MinHeight="300"
    d:DesignWidth="960" d:DesignHeight="600">
    <UserControl.Resources>
        <Style x:Key="BorderRoot" TargetType="Border">
            <Setter Property="Background" Value="Seashell" />
            <Setter Property="BorderBrush" Value="Black"/>
            <Setter Property="BorderThickness" Value="1" />
        </Style>

        <Style x:Key="ClientGridSplitter" TargetType="sdkctrls:GridSplitter">
            <Setter Property="Background" Value="#FFE0EEE0" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
        </Style>

        <vm:ClientViewModel x:Key="ClientViewModelDataSource" d:IsDataSource="True"/>

        <Style TargetType="sdkctrls:HeaderedItemsControl">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="sdkctrls:HeaderedItemsControl">
                        <StackPanel>
                            <ItemsPresenter Margin="10,0,0,0" />
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="ScrollViewerIndexItems" TargetType="ScrollViewer">
            <Setter Property="Margin" Value="10" />
            <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
        </Style>

        <Style x:Key="StackPanelIndexItems" TargetType="toolkit:DockPanel">
            <Setter Property="Background" Value="#ff9" />
        </Style>

        <DataTemplate x:Key="HierarchicalHeaderTemplate">
            <TextBlock FontSize="24" FontWeight="Bold" Text="{Binding}" />
        </DataTemplate>

        <sdk:HierarchicalDataTemplate x:Key="HierarchicalItemTemplate">
            <HyperlinkButton
                ClickMode="Press"
                Command="{Binding IndexItemCommand, Source={StaticResource ClientViewModelDataSource}}"
                CommandParameter="{Binding Url}"
                FontSize="12">
                <HyperlinkButton.Content>
                    <TextBlock Text="{Binding Text}" />
                </HyperlinkButton.Content>
            </HyperlinkButton>
        </sdk:HierarchicalDataTemplate>

        <sdk:HierarchicalDataTemplate x:Key="HierarchicalBodyTemplate">
            <StackPanel>
                <TextBlock FontSize="12" FontWeight="Bold" Margin="0,10,0,0" Text="{Binding Text}" />
                <sdkctrls:HeaderedItemsControl
                    ItemsSource="{Binding Outlines}" Margin="10,0,10,0"
                    ItemTemplate="{StaticResource HierarchicalItemTemplate}">
                </sdkctrls:HeaderedItemsControl>
            </StackPanel>
        </sdk:HierarchicalDataTemplate>
    </UserControl.Resources>

    <UserControl.DataContext>
        <Binding Source="{StaticResource ClientViewModelDataSource}"/>
    </UserControl.DataContext>

<toolkitInput:ContextMenuService.ContextMenu>
        <toolkitInput:ContextMenu>
            <toolkitInput:MenuItem Header="Toggle Full-Embedding" Command="{Binding ClientCommand}" CommandParameter="#togglefullembed" />
            <toolkitInput:MenuItem Header="Toggle Full-Screen" Click="FullScreenClick" />
            <toolkitInput:Separator />
            <toolkitInput:MenuItem Header="About…" Command="{Binding ClientCommand}" CommandParameter="#about">
                <toolkitInput:MenuItem.Icon>
                    <Path
                        Data="F1M116.60986,248.75098L116.60986,266.76611L108.86426,266.76611L108.86426,248.75098L96.06543,248.75098L96.06543,268.1333L88.31982,268.1333L88.31982,248.75098L75.521,248.75098L75.521,269.5L67.77539,269.5L67.77539,241.72705L129.56885,241.72705C129.5791,235.72412,126.15479,231.19092,119.86523,231.19092L68.17578,231.19092L68.17578,224.16797C68.17578,214.53271,75.73535,206.58691,85.46484,206.60791L130.48047,206.70459C130.50537,200.05762,126.61963,196.14697,119.86523,196.16895L68.17578,196.3418L68.17578,189.31787C68.17578,179.67676,75.74219,171.75781,85.46484,171.75781L136.66797,171.75781L136.66797,178.78223L85.46484,178.78223C78.24805,178.78223,75.91162,182.98779,74.98584,189.23389L119.86523,189.14502C129.59619,189.12598,137.1543,197.06982,137.1543,206.70459L137.1543,213.729L85.46484,213.63135C78.70752,213.61865,74.82471,217.51074,74.8501,224.16797L119.86523,224.16797C129.58936,224.16797,137.1543,232.0874,137.1543,241.72705L137.1543,265.39941L129.40869,265.39941L129.40869,248.75098L116.60986,248.75098z"
                        Fill="#FFCCFF00"
                        Stretch="UniformToFill"
                        Width="23.126" Height="32.581"
                        />
                </toolkitInput:MenuItem.Icon>
            </toolkitInput:MenuItem>
        </toolkitInput:ContextMenu>
    </toolkitInput:ContextMenuService.ContextMenu>

    <Border Style="{StaticResource BorderRoot}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="30*" MinHeight="128" />
                <RowDefinition Height="2*" />
                <RowDefinition Height="63*" MinHeight="300" />
                <RowDefinition Height="5*" />
            </Grid.RowDefinitions>
            <v:HeaderView Grid.Row="0" />
            <sdkctrls:GridSplitter Grid.Row="1" Style="{StaticResource ClientGridSplitter}" />
            <toolkit:DockPanel Grid.Row="2"
                    LastChildFill="True"
                    Style="{StaticResource StackPanelIndexItems}"
                    Width="Auto" Height="Auto">
                <ScrollViewer toolkit:DockPanel.Dock="Left"
                        Style="{StaticResource ScrollViewerIndexItems}">
                    <sdkctrls:HeaderedItemsControl
                            Header="{Binding IndexTitle}"
                            HeaderTemplate="{StaticResource HierarchicalHeaderTemplate}"
                            ItemsSource="{Binding Outlines}"
                            ItemTemplate="{StaticResource HierarchicalBodyTemplate}">
                    </sdkctrls:HeaderedItemsControl>
                </ScrollViewer>
                <navigation:Frame x:Name="IndexFrame"
                        toolkit:DockPanel.Dock="Right"
                        Height="Auto"
                        />
            </toolkit:DockPanel>
            <v:FooterView Grid.Row="3" />
        </Grid>
    </Border>
</UserControl>
